package com.wyyc.common.car.controller;

import com.alibaba.fastjson.JSON;
import com.wyyc.common.car.service.CarService;
import com.wyyc.entity.ResJson;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Hwei~ on 2017/6/7.
 */
@Controller
@RequestMapping("request/car/")
public class CarController {

    @Resource
    private CarService carService;

    @RequestMapping(value = "getMyCar",method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    @ResponseBody
    public String getMyCar(Integer uid){
        if (uid!=null){
            ResJson resJson = carService.getMyCar(uid);
            return JSON.toJSONString(resJson);
        }
        return "";
    }

    @RequestMapping(value = "addMyCar",method = RequestMethod.POST,produces = "text/html;charset=UTF-8")
    @ResponseBody
    public String addMyCar(Integer uid,String hphm,String cityCode,String classno,String engineno,String name,String phone){
        ResJson resJson = carService.addMyCar(uid, hphm, cityCode, classno, engineno, name, phone);
        return JSON.toJSONString(resJson);
    }

}
